package health

import "time"

// HealthResponse 基础健康检查响应
type HealthResponse struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

// HealthDetailedResponse 详细健康检查响应
type HealthDetailedResponse struct {
	Status    string                 `json:"status"`
	Timestamp time.Time              `json:"timestamp"`
	Database  DatabaseHealthStatus   `json:"database"`
	Services  map[string]interface{} `json:"services,omitempty"`
	Version   string                 `json:"version,omitempty"`
	Uptime    string                 `json:"uptime,omitempty"`
	Error     string                 `json:"error,omitempty"`
}

// DatabaseHealthStatus 数据库健康状态
type DatabaseHealthStatus struct {
	Status      string    `json:"status"`
	Ping        bool      `json:"ping"`
	Connections int       `json:"connections"`
	LastCheck   time.Time `json:"last_check"`
	Error       string    `json:"error,omitempty"`
}

// DatabaseMetricsResponse 数据库指标响应
type DatabaseMetricsResponse struct {
	Connections ConnectionMetrics  `json:"connections"`
	Performance PerformanceMetrics `json:"performance"`
	Storage     StorageMetrics     `json:"storage"`
	Timestamp   time.Time          `json:"timestamp"`
}

// ConnectionMetrics 连接指标
type ConnectionMetrics struct {
	Active    int `json:"active"`
	Idle      int `json:"idle"`
	Total     int `json:"total"`
	MaxOpen   int `json:"max_open"`
	MaxIdle   int `json:"max_idle"`
	WaitCount int `json:"wait_count"`
}

// PerformanceMetrics 性能指标
type PerformanceMetrics struct {
	QueriesPerSecond float64       `json:"queries_per_second"`
	AvgQueryTime     time.Duration `json:"avg_query_time"`
	SlowQueries      int           `json:"slow_queries"`
}

// StorageMetrics 存储指标
type StorageMetrics struct {
	DatabaseSize string `json:"database_size"`
	TableCount   int    `json:"table_count"`
	IndexSize    string `json:"index_size"`
}

// TableSizeInfo 表大小信息
type TableSizeInfo struct {
	TableName string `json:"table_name"`
	RowCount  int64  `json:"row_count"`
	DataSize  string `json:"data_size"`
	IndexSize string `json:"index_size"`
	TotalSize string `json:"total_size"`
}

// TableSizesResponse 表大小响应
type TableSizesResponse struct {
	Tables    []TableSizeInfo `json:"tables"`
	TotalSize string          `json:"total_size"`
	Timestamp time.Time       `json:"timestamp"`
}
